package com.haiyi.software.app.basic;

import org.jivesoftware.smack.packet.Message;

import android.R.color;
import android.app.Application;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;

import com.haiyi.software.app.MainActivity;
import com.haiyi.software.app.R;

public abstract class MainApplicationBasic extends Application {

	protected void showNotification(Message msg) {

		NotificationManager nManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

		Notification notification = new Notification(R.drawable.app395,
				"有新的消息...", System.currentTimeMillis());

		notification.defaults |= Notification.DEFAULT_LIGHTS;
		notification.flags |= Notification.FLAG_AUTO_CANCEL;
		notification.defaults |= Notification.DEFAULT_SOUND;

		Intent intent = new Intent();
		intent.setClass(getApplicationContext(), MainActivity.class);
		intent.putExtra("notify", "nofity");
		// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
		// | Intent.FLAG_ACTIVITY_NEW_TASK);

		PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

		notification.setLatestEventInfo(this, "新的消息", "您有新的消息", pIntent);

		nManager.notify(R.string.app_name, notification);

	}
}
